<template>
	<view>
		<!-- 主体部分 -->
		<basics v-if="PageCur=='index'"></basics>
		<course v-if="PageCur=='course'"></course>
		<person v-if="PageCur=='person'"></person>
		<!-- 底部导航栏 -->
		<view class="cu-bar tabbar bg-white shadow foot">
			<view class="action" @click="NavChange" data-cur="index">
				<view class='cuIcon-cu-image'>
					<image :src="'/static/tabbar/index' + [PageCur=='index'?'_cur':''] + '.png'"></image>
				</view>
				<view class="text-lg" :class="PageCur=='index'?'text-green':'text-gray'">精选</view>
			</view>
			<view class="action" @click="NavChange" data-cur="course">
				<view class='cuIcon-cu-image'>
					<image :src="'/static/tabbar/course' + [PageCur == 'course'?'_cur':''] + '.png'"></image>
				</view>
				<view class="text-lg" :class="PageCur=='course'?'text-green':'text-gray'">我的课程</view>
			</view>
			<view class="action" @click="NavChange" data-cur="person">
				<view class='cuIcon-cu-image'>
					<image :src="'/static/tabbar/person' + [PageCur == 'person'?'_cur':''] + '.png'"></image>
				</view>
				<view class="text-lg" :class="PageCur=='person'?'text-green':'text-gray'">个人中心</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapGetters } from "vuex"
	import Basics from '../basics/basics.vue'
	import Course from '../course/course.vue'
	import Person from '../person/person.vue'
	export default {
		components:{
			Basics,
			Course,
			Person
		},
		data() {
			return {
				title: 'Index',
				// 底部导航栏
				PageCur: 'person'
			}
		},
		created() {
			console.log("小程序启动");
			//#ifndef MP-WEIXIN
			this.isMobile()
			//#endif
		},
		onLoad() {

		},
		computed: {
			...mapGetters(['pagecur'])
		},
		watch: {
			pagecur: function(newVal, old){
				this.PageCur = newVal
			}
		},
		methods: {
			NavChange: function(e) {
				this.PageCur = e.currentTarget.dataset.cur
				this.$store.commit("setting/set_pagecur", e.currentTarget.dataset.cur)
			},
			// 判断设备类型
			isMobile() {
				const flag = /Android|iPhone|iPad|iPod|BlackBerry|webOS|Windows Phone|SymbianOS|IEMobile|Opera Mini/i.test(navigator.userAgent)
				if (flag) {
					// 移动端设备
				} else {
					// PC端
					window.location.href = "https://children.mumuwei.xyz"
				}
			}
		}
	}
</script>

<style>
</style>
